package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Address;
import cn.wolfcode.trip.base.mapper.AddressMapper;
import cn.wolfcode.trip.base.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements IAddressService {
    @Autowired
    private AddressMapper addressMapper;

    public List<Address> listAddresses(Long userId) {
        List<Address> addresses = addressMapper.selectAll(userId);
        return addresses;
    }

    public Address getAddress(Long id) {
        return addressMapper.selectByPrimaryKey(id);
    }

    public void save(Address address) {

        addressMapper.insert(address);
    }

    public void update(Address address) {
        addressMapper.updateByPrimaryKey(address);
    }
}
